<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			ul li{
				background: pink;
			}
		
			.btn{
				width: 100px;
				height: 30px;
				background: skyblue;
				font-size: 12px;
				line-height: 30px;
				text-align: center;	
			}
			
			.change-bg{
				background: deepskyblue;
			}
		</style>
	</head>
	<body>
		<ul>
			<li>01</li>
			<li>02</li>
			<li>03</li>
			<li>04</li>
			<li>05</li>
		</ul>
		<div class="btn">颜色切换</div>
		<script>
			var ul = document.querySelector('ul');
			var btn = document.querySelector('.btn');
			btn.addEventListener('click', function (){
				for ( var i = 0; i < ul.children.length; i++ ) {
					if ( i % 2 == 0 ){
						ul.children[i].classList.toggle('change-bg');
					}
				}
			});
		</script>
	</body>
</html>
